package com.qs.mall.util;

import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.Map;

@Slf4j
@Component
public class CacheManageUtil {


    public static Map<String, String> resultMap = new HashMap<>();


    @PostConstruct
    public void init() {
        resultMap.put("name", "张三");
        resultMap.put("age", "30");
        log.info("====>>>>resultMap={}", resultMap);
    }

    @Scheduled(cron = "0/5 * * * * ?")
    public void syncMap() {
        resultMap = new HashMap<>();
        resultMap.put("name", "李四");
        resultMap.put("age", "100");
        log.info("----->>>resultMap={}", resultMap);
    }

}
